home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Plotting / aa_Intel_Only / Gnuplot / GnuplotSource / EditMatrix.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  1.9 KB  |  114 lines

  1. /*
  2.  *  Copyright (C) 1993  Robert Davis
  3.  *
  4.  *  This program is free software; you can redistribute it and/or
  5.  *  modify it under the terms of Version 2, or any later version, of 
  6.  *  the GNU General Public License as published by the Free Software 
  7.  *  Foundation.
  8.  */
  9.  
  10. static char RCSId[]="$Id: EditMatrix.m,v 1.5 1993/05/18 03:55:01 davis Exp $";
  11.  
  12.  
  13. #import <appkit/TextFieldCell.h>
  14. #import "EditMatrix.h"
  15.  
  16. @interface EditMatrix (Private)
  17.  
  18. - (BOOL)_incrementCount:sender;
  19.  
  20. @end
  21.  
  22.  
  23. @implementation EditMatrix
  24.  
  25. - initFrame:(const NXRect *)frameRect
  26. {
  27.     [super initFrame:frameRect];
  28.     editableCells = NO;
  29.  
  30.     return self;
  31. }
  32.  
  33.  
  34. - setEditableCells:(BOOL)aCond
  35. {
  36.     editableCells = aCond;
  37.     return self;
  38. }
  39.  
  40.  
  41. - (BOOL)editableCells
  42. {
  43.     return editableCells;
  44. }
  45.  
  46.  
  47. - mouseDown:(NXEvent *)theEvent
  48. {
  49.     /*  
  50.      *  If there's a double-click, and if editableCells is turned on, 
  51.      *  allow the cell to be edited.
  52.      */
  53.     
  54.     if (editableCells && theEvent->data.mouse.click == 2)
  55.     [editingCell = [self selectedCell] setEditable:YES];
  56.  
  57.     /*  Clicking outside the cell should end editing  */
  58.  
  59.     if (editingCell && [window makeFirstResponder:window] )
  60.     [window endEditingFor:nil];
  61.  
  62.     return [super mouseDown:theEvent];
  63. }
  64.  
  65.  
  66.  
  67. - textDidEnd:textObject endChar:(short unsigned)whyEnd
  68. {
  69.     [editingCell setEditable:NO];
  70.     editingCell = nil;
  71.  
  72.     return [super textDidEnd:textObject endChar:whyEnd];
  73. }
  74.  
  75.  
  76.  
  77. - (BOOL)multipleCellsSelected
  78. {
  79.     selectedCount = 0;
  80.     
  81.     [self sendAction:@selector(_incrementCount:) to:self forAllCells:NO];
  82.     return (selectedCount > 1);
  83. }
  84.  
  85.  
  86. - selectedCell
  87. {
  88.     if ([self multipleCellsSelected])
  89.     return nil;
  90.     else
  91.     return [super selectedCell];
  92. }
  93.  
  94.  
  95. // Shuts up the compiler about unused RCSId
  96. - (const char *) rcsid
  97. {
  98.     return RCSId;
  99. }
  100.  
  101.  
  102. @end
  103.  
  104.  
  105. @implementation EditMatrix (Private)
  106.  
  107. - (BOOL)_incrementCount:sender
  108. {
  109.     return (++selectedCount < 2);
  110. }
  111.  
  112.  
  113. @end
  114.